<template>
  <div>
    <Card title="导出市对县指标分析报告">
      <DatePicker
        type="month"
        v-model="downloadWordDate"
        @on-change="downloadWord"
        format="yyyyMM"
        placeholder="请选择导出日期(必填)"
        style="width: 200px;"
      ></DatePicker>排名前
      <InputNumber placeholder="(必填)" v-model="topNum" :min="1" style="width:70px;"></InputNumber>名
      <Button type="success" @click="downloadWordFile">导出市对县指标分析报告</Button>
    </Card>
  </div>
</template>
<script>
import { URL } from "@/libs/util";
// 以防命名冲突
const HOST = URL;

export default {
  data() {
    return {
      downloadWordDate: "", // 下载word日期
      topNum: null, // 排名前几名
      orderBy: "" // 排名单选框
    };
  },
  methods: {
    // 获取下载word时间
    downloadWord(date) {
      this.downloadWordDate = date;
    },
    // 导出word 分析报告
    downloadWordFile() {
      if (this.downloadWordDate !== "" && this.topNum !== null) {
        let times = this.downloadWordDate;
        let topNum = this.topNum;
        window.open(
          HOST +
            "/countryIndicators/cityIndexReport?datetime=" +
            times +
            "&topNum=" +
            topNum
        );
        this.downLoadModal = false;
      } else {
        this.$Notice.error({
          title: "请选择导出日期 或者 导出排名",
          duration: 3.5
        });
      }
    }
  },
  created() {}
};
</script>
